package com.sfac.day03.modules.account.dao;

import com.sfac.day03.modules.account.entity.RoleResource;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface RoleResourceDao {
    @Insert("insert into account_role_resource (role_id, resource_id) values (#{roleId}, #{resourceId})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insertRoleResource(RoleResource roleResource);

    @Delete("delete from account_role_resource where resource_id = #{resourceId}")
    int deleteRoleResourceByResourceId(int resourceId);

    @Delete("delete from account_role_resource where role_id = #{roleId}")
    int deleteRoleResourceByRoleId(int roleId);
}
